﻿@{
    ViewBag.Title = "日志管理_按用户（账户）查询";
}
<script type="text/javascript">

    var LastSelectID = 0; //最后一次选中的行ID
    $(document).ready(function () {
        GridGet_QueryUser();
    });

    function GridGet_QueryUser() {
        $("#List_Permission_Log_QueryUser").jqGrid({
            url: "/Permission/Log/QueryByUser",
            datatype: "json",
            mtype: "post",
            colModel: [
                        { label: 'Id', name: 'LogId', index: 'LogId', width: 5, align: "center", sortable: false, hidden: true },
                        { label: '模块', name: 'ProcessName', index: 'ProcessName', width: 120, align: "center", sortable: false },
                        { label: '用户', name: 'UserRealName', index: 'UserRealName', width: 100, align: "center", sortable: false },
                        { label: '访问时间', name: 'CreateOn', index: 'CreateOn', formatter: 'date', formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' }, datefmt: 'Y-m-d H:i:s', width: 150, align: "center", sortable: false },
                        { label: 'IP地址', name: 'IPAddress', index: 'IPAddress', width: 150, align: "center", sortable: false },
                        { label: '操作', name: 'MethodName', index: 'MethodName', width: 200, align: "center", sortable: false },
                        { label: '描述', name: 'Description', index: 'Description', width: 100, align: "center", sortable: false }
                       ],
            beforeRequest: function (d) {
                $(this).jqGrid('setGridParam', { postData: { "userid": $("#userId_SelectUser").val(), "startDate": $("#txtStartDate").val(), "endDate": $("#txtEndDate").val()} });
            },
            loadError: function (xhr, status) {
                alertMsg.error(xhr.responseText);
            },
            loadComplete: function (xhr) {
                var ajaxbg = $("#background,#progressBar,#lui_List_Permission_Log_QueryUser");
                ajaxbg.hide();
            },
            onSelectRow: User_GetLogList,
            autowidth: true,
            shrinkToFit: true,
            multiselect: false,
            multiselectWidth: 23,
            sortable: false,
            viewrecords: true,
            sortorder: "desc",
            jsonReader: {
                repeatitems: false
            },
            height: 370
        }).navGrid('#pager_Permission_Log_QueryUser', { edit: false, add: false, del: false, refresh: false, search: false });
    }
    //选中某一行，获得行
    function User_GetLogList() {
        var GridObj = $("#List_Permission_Log_QueryUser");
        var logIds = GridObj.jqGrid("getGridParam", "selrow");
        if (logIds == "")
            return "";
        var temp = GridObj.getCell(parseInt(logIds), "LogId").toString();

        return temp;
    }
    //对用户登录情况执行删除操作
    //    $("#del_Permission_Log_QueryUser").click(function () {
    //        var SelectLogIds = User_GetLogList();
    //        if (SelectLogIds == "") {
    //            alertMsg.error("至少要勾选一条记录！");
    //            return false;
    //        }
    //        else {
    //            alertMsg.confirm("确定要删除吗？", {
    //                okCall: function () {
    //                    $.post("/Permission/Log/Delete", { "ids": SelectLogIds }, function (json) {
    //                        //1 接收参数 2 判断成功与否 3 根据返回的数据在树上新增节点
    //                        DWZ.ajaxDone(json);
    //                        if (json.statusCode == DWZ.statusCode.ok) {
    //                            //更新JqGrid
    //                            var rowIds = $("#List_Permission_Log_QueryUser").jqGrid("getGridParam", "selarrrow").toString();
    //                            var ids_arry = rowIds.split(',');
    //                            for (var i = 0; i < ids_arry.length; i++) {
    //                                $("#List_Permission_Log_QueryUser").delRowData(ids_arry[i]);
    //                            }
    //                            alertMsg.correct("成功删除" + ids_arry.length.toString() + "条记录！");
    //                        }
    //                        else {
    //                            alertMsg.error("删除失败,请稍后再试！");
    //                        }
    //                    }, "json");
    //                }
    //            });
    //        }
    //    });
    //对用户登录情况执行全部删除操作
    //    $("#delAll_Permission_Log_QueryUser").click(function () {
    //        alertMsg.confirm("确定要全部清除吗？", {
    //            okCall: function () {
    //                $.post("/Permission/Log/Delete", { "ids": 0 }, function (json) {
    //                    //1 接收参数 2 判断成功与否 3 根据返回的数据在树上新增节点
    //                    DWZ.ajaxDone(json);
    //                    if (json.statusCode == DWZ.statusCode.ok) {
    //                        //清除所有JqGrid的数据行                           
    //                        $("#List_Permission_Log_QueryUser").clearGridData(true);
    //                        alertMsg.correct("全部清除完毕！");
    //                    }
    //                    else {
    //                        alertMsg.error("删除失败,请稍后再试！");
    //                    }
    //                }, "json");
    //            }
    //        });
    //    });
    //按条件查询日志
    $("#btnQuery_Permission_Log_QueryUser").click(function () {
        $("#List_Permission_Log_QueryUser").trigger("reloadGrid"); //重新加载JqGrid ;
    });
</script>
<div class="pageContent" layouth="3">
    <ul class="searchBar">
        <li><span>
            <input type="hidden" id="userId_SelectUser" value="@ViewBag.Id" />用户：</span>
            <input type="text" id="txtUserName_SelectUser" readonly="readonly" value="@ViewBag.UserName" />
            <a class="btnLook" href="/Permission/Log/SelectUser/1" target="dialog" rel="dialog_permisson_log_Module"
                title="切换用户" mask="true" width="560" height="400">选择</a> </li>
        <li><span>开始日期：</span>
            <input type="text" id="txtStartDate" value="@ViewBag.startDate" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'txtEndDate\',{H:0});}',readOnly:true});" />
        </li>
        <li><span>结束日期：</span>
            <input type="text" id="txtEndDate" value="@ViewBag.endDate" onclick="WdatePicker({minDate:'#F{$dp.$D(\'txtStartDate\',{H:1});}',readOnly:true});" />
        </li>
        <li>
            <input type="button" id="btnQuery_Permission_Log_QueryUser" class="btn btn-success btn-xs"
                value="查询" />
        </li>
    </ul>
    <div id="mainContent_Permission_Log_QueryUser">
        <div class="tableList jqgridLayout">
            <table class="jqgrid" id="List_Permission_Log_QueryUser">
            </table>
            <div id="pager_Permission_Log_QueryUser">
            </div>
        </div>
    </div>
</div>
